package com.hong.spring.grpc;

import com.hong.spring.Greeting;
import com.hong.spring.HelloResp;
import com.hong.spring.HelloWorldGrpc;
import io.grpc.stub.StreamObserver;

/**
 *
 * 功能描述: 响应接口
 *
 * @param:
 * @return:
 * @auther: csh
 * @date: 2021/1/27 11:45
 */
public class HelloWorldRpcService extends HelloWorldGrpc.HelloWorldImplBase {

    @Override
    public void sayHello(Greeting request, StreamObserver<HelloResp> responseObserver) {
        String name = request.getName();
        HelloResp resp = HelloResp.newBuilder()
                .setReply("Hello " + name + "!")
                .build();
        responseObserver.onNext(resp);
        responseObserver.onCompleted();
    }
}